package com.fancy.projecty.controller;

import com.fancy.projecty.mapper.AskForLeaveMapper;
import com.fancy.projecty.util.SuccessVo;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RequestMapping("/EndFlowInstanceController")
@RestController
@CrossOrigin
@Api(tags = "已经完成的流程实例")
public class EndFlowInstanceController {
	@Autowired
	private AskForLeaveMapper askForLeaveMapper;

	@Autowired
	private RuntimeService runtimeService;
	@Autowired
	private TaskService taskService;


	/**
	 * 查询已经完成的流程实例
	 */
	@ApiOperation(value = "查询已经完成的流程实例")
	@PostMapping("/selectEndFlowInstance")
	@Transactional
	@RequiresPermissions("workFlow")
	public SuccessVo selectEndFlowInstance(@RequestBody Map map) {

		PageHelper.startPage(map);
		List<Map> listMap = this.askForLeaveMapper.selectEndFlowInstance(map);

		return new SuccessVo(new PageInfo<>(listMap));

	}


	/**
	 * 查询没有完成的流程实例
	 */
	@ApiOperation(value = "查询没有完成的流程实例")
	@PostMapping("/selectNotEndFlowInstance")
	@Transactional
	@RequiresPermissions("workFlow")
	public SuccessVo selectNotEndFlowInstance(@RequestBody Map map) {

		PageHelper.startPage(map);
		List<Map> listMap = this.askForLeaveMapper.selectNotEndFlowInstance(map);

		return new SuccessVo(new PageInfo<>(listMap));

	}

}
